#include <bits/stdc++.h>
using namespace std;
const int maxn=200005;

bool check(int a[],int n)
{
	if(n%2==1)
	{
		if(a[1]>a[2]||a[1]>a[3])
		{
			return false;
		}
		for(int i=2;i<=n-3;i=i+2)
		{
			if(a[i]>a[i+2]||a[i]>a[i+3]||a[i+1]>a[i+2]||a[i+1]>a[i+3])
			{
				return false;
			}
		}
	    return true;
	}
	else if(n%2==0)
	{
		for(int i=1;i<=n-3;i=i+2)
		{
			if(a[i]>a[i+2]||a[i]>a[i+3]||a[i+1]>a[i+2]||a[i+1]>a[i+3])
			{
				return false;
			}
		}
	    return true;
	}
}

int main()
{
	int t;
	cin >> t;
	while(t--)
	{
		int a[maxn];
		int n;
		cin >> n;
		for(int i=1;i<=n;i++)
		{
			cin >> a[i];
		}
		if(n==1||n==2)
		{
			cout << "YES\n";
		}
		else if(n>=3)
		{
			if(check(a,n))
		    {
			    cout << "YES\n";
		    }
		    else if(!check(a,n))
		    {
			    cout << "NO\n";
		    }
		}
	}
	return 0;
}
